<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="数据库," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="人的一切痛苦，本质上都是对自己的无能的愤怒。  基础 nal(a,b)当a为Null的时候取值b，当a不为null时。 select * from money is null ,—–查询money字段为空值的记录 oracle 别名 和Mysql 一样. sekect distinct money from emp —查询emp表中所有的钱的数量，去除重复。distinct这个关键字表示去重.">
<meta name="keywords" content="数据库">
<meta property="og:type" content="article">
<meta property="og:title" content="数据库-oracle基础">
<meta property="og:url" content="http://yoursite.com/2017/05/17/数据库-oracle基础/index.html">
<meta property="og:site_name" content="JokerLiang">
<meta property="og:description" content="人的一切痛苦，本质上都是对自己的无能的愤怒。  基础 nal(a,b)当a为Null的时候取值b，当a不为null时。 select * from money is null ,—–查询money字段为空值的记录 oracle 别名 和Mysql 一样. sekect distinct money from emp —查询emp表中所有的钱的数量，去除重复。distinct这个关键字表示去重.">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-05-17T09:37:37.528Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="数据库-oracle基础">
<meta name="twitter:description" content="人的一切痛苦，本质上都是对自己的无能的愤怒。  基础 nal(a,b)当a为Null的时候取值b，当a不为null时。 select * from money is null ,—–查询money字段为空值的记录 oracle 别名 和Mysql 一样. sekect distinct money from emp —查询emp表中所有的钱的数量，去除重复。distinct这个关键字表示去重.">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"always"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/05/17/数据库-oracle基础/"/>





  <title> 数据库-oracle基础 | JokerLiang </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  








  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=1260895995&web_id=1260895995" language="JavaScript"></script>
  </div>





  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">JokerLiang</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">永远年轻，永远热泪盈眶。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/17/数据库-oracle基础/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="JokerLiang">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/me.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="JokerLiang">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="JokerLiang" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                数据库-oracle基础
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-05-17T08:02:17+08:00">
                2017-05-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/数据库/" itemprop="url" rel="index">
                    <span itemprop="name">数据库</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>&#x4EBA;&#x7684;&#x4E00;&#x5207;&#x75DB;&#x82E6;&#xFF0C;&#x672C;&#x8D28;&#x4E0A;&#x90FD;&#x662F;&#x5BF9;&#x81EA;&#x5DF1;&#x7684;&#x65E0;&#x80FD;&#x7684;&#x6124;&#x6012;&#x3002;</p>
</blockquote>
<h2 id="&#x57FA;&#x7840;"><a href="#&#x57FA;&#x7840;" class="headerlink" title="&#x57FA;&#x7840;"></a>&#x57FA;&#x7840;</h2><ul>
<li>nal(a,b)&#x5F53;a&#x4E3A;Null&#x7684;&#x65F6;&#x5019;&#x53D6;&#x503C;b&#xFF0C;&#x5F53;a&#x4E0D;&#x4E3A;null&#x65F6;&#x3002;</li>
<li>select * from money is null ,&#x2014;&#x2013;&#x67E5;&#x8BE2;money&#x5B57;&#x6BB5;&#x4E3A;&#x7A7A;&#x503C;&#x7684;&#x8BB0;&#x5F55;</li>
<li>oracle &#x522B;&#x540D; &#x548C;Mysql &#x4E00;&#x6837;.</li>
<li>sekect distinct money from emp &#x2014;&#x67E5;&#x8BE2;emp&#x8868;&#x4E2D;&#x6240;&#x6709;&#x7684;&#x94B1;&#x7684;&#x6570;&#x91CF;&#xFF0C;&#x53BB;&#x9664;&#x91CD;&#x590D;&#x3002;distinct&#x8FD9;&#x4E2A;&#x5173;&#x952E;&#x5B57;&#x8868;&#x793A;&#x53BB;&#x91CD;.</li>
<li>&#x5728;Oracle&#x4E2D;&#x5355;&#x5F15;&#x53F7;&#x8868;&#x793A;&#x65E5;&#x671F;&#x548C;&#x5B57;&#x7B26;&#xFF0C;&#x53CC;&#x5F15;&#x53F7;&#x8868;&#x793A;&#x5217;&#x7684;&#x522B;&#x540D;&#x3002;</li>
<li>between a and b &#x67E5;&#x8BE2;&#x5927;&#x4E8E;&#x7B49;&#x4E8E;a&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;b&#x7684;&#x503C;</li>
<li>like &#x6A21;&#x7CCA;&#x67E5;&#x8BE2; %&#x8868;&#x793A;&#x4EFB;&#x610F;&#x957F;&#x5EA6;&#x7684;&#x4EFB;&#x610F;&#x5B57;&#x7B26;&#x4E32;  _&#x8868;&#x793A;&#x4EFB;&#x610F;&#x5B57;&#x7B26;&#x7684;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;, \&#x8868;&#x793A;&#x8F6C;&#x4E49;&#x5B57;&#x7B26;.</li>
<li>&#x5728;and&#x8BED;&#x53E5;&#x4E2D;&#xFF0C;where&#x89E3;&#x6790;&#x987A;&#x5E8F; &#x53F3;&#x2014;-&gt;&#x5DE6;</li>
<li>order by &#x540E;&#x9762; +&#x5217;&#x3001;&#x8868;&#x8FBE;&#x5F0F;&#x3001;&#x522B;&#x540D;&#x3001;&#x5E8F;&#x53F7; + &#x6392;&#x5E8F;&#x89C4;&#x5219; asc desc</li>
<li>order by &#x4F5C;&#x7528;&#x4E8E;&#x540E;&#x9762;&#x6240;&#x6709;&#x7684;&#x5217;&#xFF0C;&#x5148;&#x6309;&#x7167;&#x7B2C;&#x4E00;&#x4E2A;&#x5217;&#x6392;&#x5E8F;&#xFF0C;&#x518D;&#x540E;&#x9762;&#x7684;&#x5217;&#xFF0C;desc&#x964D;&#x5E8F; &#x5236;&#x4F5C;&#x7528;&#x4E8E;&#x79BB;&#x4ED6;&#x6700;&#x8FD1;&#x7684;&#x5217;&#x3002;</li>
<li>nulls last &#x8868;&#x793A;&#x5982;&#x679C;&#x6709;&#x7A7A;&#x503C;&#xFF0C;&#x7A7A;&#x503C;&#x653E;&#x5728;&#x6700;&#x540E;  select * from emp order by money desc nulls last  &#x5347;&#x5E8F;&#x65F6;&#x6CA1;&#x6709;&#x95EE;&#x9898;&#x3002;&#x56E0;&#x4E3A;&#x5728;oracle&#x6570;&#x636E;&#x5E93;&#x4E2D;&#xFF0C;null&#x6700;&#x5927;</li>
<li>dual &#x4E3A;oracle&#x4E2D;&#x6CA1;&#x6709;&#x610F;&#x4E49;&#x7684;&#x7A7A;&#x8868;</li>
<li>&#x53BB;&#x6389;delect&#x4EA7;&#x751F;&#x540E;&#x7684;&#x788E;&#x7247; alter table &lt;&#x8868;&#x540D;&gt;mover &#x63D0;&#x9AD8;&#x67E5;&#x8BE2;&#x901F;&#x5EA6;</li>
<li>rownum &#x884C;&#x53F7; select rownum from a &#xFF0C; rownum&#x6C38;&#x8FDC;&#x6309;&#x7167;&#x9ED8;&#x8BA4;&#xFF08;&#x5373;&#x4F7F;&#x6392;&#x5B8C;&#x5E8F;&#x540E;&#x884C;&#x53F7;&#x4E5F;&#x4E0D;&#x53D8;&#xFF09;&#x7684;&#x987A;&#x5E8F;&#xFF0C;rownum&#x53EA;&#x80FD;&#x4F7F;&#x7528;&#x5C0F;&#x4E8E;&#xFF0C;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;&#xFF0C;&#x4E0D;&#x80FD;&#x7528;&#x5176;&#x4ED6;&#x3002;</li>
<li>top-n&#x95EE;&#x9898;&#xFF1A;select f<em> from (select </em> from a order by money desc) where rownum&lt;=3.</li>
<li>&#x6240;&#x6709;&#x5305;&#x542B;&#x4E8E;select&#x5217;&#x8868;&#x4E2D;&#xFF0C;&#x800C;&#x672A;&#x5305;&#x542B;&#x4E8E;&#x7EC4;&#x51FD;&#x6570;&#x4E2D;&#x7684;&#x5217;&#xFF0C;&#x90FD;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x4E8E;GroupBy&#x5B50;&#x53E5;&#x4E2D;&#x3002;&#x5305;&#x542B;&#x5728;Group&#x5B50;&#x53E5;&#x4E2D;&#x7684;&#x5217;&#xFF0C;&#x4E0D;&#x4E00;&#x5B9A;&#x8981;&#x5305;&#x542B;&#x5728;select&#x4E2D;&#x3002;</li>
<li>&#x591A;&#x4E2A;&#x5217;&#x7684;&#x5206;&#x7EC4;&#xFF1A;&#x5148;&#x6309;&#x7167;&#x7B2C;&#x4E00;&#x4E2A;&#x5217;&#x5206;&#x7EC4;&#xFF0C;&#x5982;&#x679C;&#x76F8;&#x540C;&#xFF0C;&#x518D;&#x6309;&#x7167;&#x7B2C;&#x4E8C;&#x4E2A;&#x5217;&#x5206;&#x7EC4;&#xFF0C;&#x4EE5;&#x6B64;&#x7C7B;&#x63A8;&#x3002;  </li>
<li>having&#x8BED;&#x53E5;&#xFF1A;&#x4ECE;&#x5206;&#x7EC4;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x8FC7;&#x6EE4;&#x3002;select b avg(c) from table group by b having avg(c)&gt;2000.&#x548C;where&#x7684;&#x533A;&#x522B;&#x662F;&#xFF0C;having&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x7EC4;&#x51FD;&#x6570;&#xFF08;&#x591A;&#x884C;&#x51FD;&#x6570;&#xFF09;&#x3002;</li>
<li>group by rollup(a,b) : &#x62A5;&#x8868;&#x5E38;&#x7528;&#x3002;</li>
</ul>
<h2 id="&#x51FD;&#x6570;"><a href="#&#x51FD;&#x6570;" class="headerlink" title="&#x51FD;&#x6570;"></a>&#x51FD;&#x6570;</h2><a id="more"></a>
<h4 id="&#x5B57;&#x7B26;&#x7C7B;&#x7684;&#x51FD;&#x6570;"><a href="#&#x5B57;&#x7B26;&#x7C7B;&#x7684;&#x51FD;&#x6570;" class="headerlink" title="&#x5B57;&#x7B26;&#x7C7B;&#x7684;&#x51FD;&#x6570;"></a>&#x5B57;&#x7B26;&#x7C7B;&#x7684;&#x51FD;&#x6570;</h4><ul>
<li>lower(&#x2018;A&#x2019;)&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x5C0F;&#x5199;</li>
<li>upper(&#x2018;a&#x2019;)&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x4E3A;&#x5927;&#x5199;</li>
<li>initcap(&#x2018;aA&#x2019;)&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;</li>
<li>substr(&#x2018;a&#x2019;,b)&#x4ECE;a&#x4E2D;&#x7B2C;b&#x4F4D;&#x5F00;&#x59CB;&#x53D6;</li>
<li>instr(&#x2018;a&#x2019;,&#x2019;b&#x2019;) &#x5728;a&#x4E2D;&#x67E5;&#x627E;b &#x67E5;&#x5230;&#x8FD4;&#x56DE;&#x4F4D;&#x7F6E; &#x6CA1;&#x67E5;&#x5230;&#x8FD4;&#x56DE;0<h4 id="&#x6570;&#x503C;&#x51FD;&#x6570;"><a href="#&#x6570;&#x503C;&#x51FD;&#x6570;" class="headerlink" title="&#x6570;&#x503C;&#x51FD;&#x6570;"></a>&#x6570;&#x503C;&#x51FD;&#x6570;</h4></li>
<li>rount() &#x56DB;&#x820D;&#x4E94;&#x5165;  round(45.926,2) =  45.93  &#x8868;&#x793A;&#x5728;45.926&#x4E2D;&#x53D6;&#x4E24;&#x4F4D;&#x5C0F;&#x6570; &#x56DB;&#x820D;&#x4E94;&#x5165;</li>
<li>trunc() &#x622A;&#x65AD; &#x7528;&#x6CD5;&#x540C;&#x4E0A;&#x76F8;&#x4F3C;<h4 id="&#x65E5;&#x671F;&#x51FD;&#x6570;"><a href="#&#x65E5;&#x671F;&#x51FD;&#x6570;" class="headerlink" title="&#x65E5;&#x671F;&#x51FD;&#x6570;"></a>&#x65E5;&#x671F;&#x51FD;&#x6570;</h4></li>
<li>to_char(a,&#x683C;&#x5F0F;)&#x5C06;a&#x6309;&#x7167;&#x683C;&#x5F0F;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32; &#x6BD4;&#x5982;&#xFF1A; to_char(sysdate,&#x2019;yyyy-mm-dd hhh24:mi:ss&#x2019;)</li>
<li>&#x5728;&#x65E5;&#x671F;&#x4E0A;&#x8FDB;&#x884C;&#x6570;&#x5B57;&#x8FD0;&#x7B97; &#x8FD8;&#x662F;&#x4E3A;&#x65E5;&#x671F; &#x6570;&#x5B57;&#x5355;&#x4F4D;&#x662F;/&#x5929;&#x3002;</li>
<li>&#x4E24;&#x4E2A;&#x65E5;&#x671F;&#x53EF;&#x4EE5;&#x76F8;&#x51CF;&#xFF0C;&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4E2D;&#x95F4;&#x5DEE;&#x7684;&#x5929;&#x6570;</li>
<li>&#x65E5;&#x671F;&#x4E0D;&#x53EF;&#x4EE5;&#x76F8;&#x52A0;&#xFF0C;&#x53EA;&#x53EF;&#x4EE5;&#x52A0;&#x6570;&#x5B57;&#x3002;</li>
<li>Months_Between(a,b)a,b &#x90FD;&#x662F;&#x65E5;&#x671F; &#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E24;&#x4E2A;&#x65E5;&#x671F;&#x76F8;&#x5DEE;&#x7684;&#x6708;&#x6570;</li>
<li>add_months(a,b)&#x5728;a&#x7684;&#x65E5;&#x671F;&#x52A0;&#x4E0A;b&#x4E2A;&#x6708;</li>
<li>last_day(a)&#x65E5;&#x671F;&#x6240;&#x5728;&#x6708;&#x4EFD;&#x7684;&#x6700;&#x540E;&#x4E00;&#x5929;</li>
<li>next_day(a&#xFF0C;&#x2019;&#x661F;&#x671F;&#x56DB;&#x2019;)&#x4ECE;a&#x5F00;&#x59CB;&#x7B97;&#xFF0C;&#x4E0B;&#x4E00;&#x4E2A;&#x661F;&#x671F;&#x56DB;&#x662F;&#x591A;&#x5C11;&#x53F7;&#x3002;<h4 id="&#x8F6C;&#x6362;&#x51FD;&#x6570;"><a href="#&#x8F6C;&#x6362;&#x51FD;&#x6570;" class="headerlink" title="&#x8F6C;&#x6362;&#x51FD;&#x6570;"></a>&#x8F6C;&#x6362;&#x51FD;&#x6570;</h4></li>
<li>to_char(a,&#x2019;b&#x2019;)&#x5C06;a&#x6309;&#x7167;b&#x7684;&#x683C;&#x5F0F;&#x8F6C;&#x5316;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</li>
<li>to_number</li>
<li>to_date </li>
<li>wm_concat()&#x884C;&#x8F6C;&#x5217;<h4 id="&#x901A;&#x7528;&#x51FD;&#x6570;"><a href="#&#x901A;&#x7528;&#x51FD;&#x6570;" class="headerlink" title="&#x901A;&#x7528;&#x51FD;&#x6570;"></a>&#x901A;&#x7528;&#x51FD;&#x6570;</h4></li>
<li>nvl2(a,b,c)&#x5F53;a=null&#x65F6;&#xFF0C;&#x8FD4;&#x56DE;c&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;b</li>
<li>nullif&#xFF08;a,b&#xFF09;&#x5F53;a=b&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8FD4;&#x56DE;Null&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;a</li>
<li>coalesce(a,b,c&#x2026;&#x2026;,z) &#x4ECE;&#x5DE6;&#x5230;&#x53F3;&#x627E;&#x5230;&#x7B2C;&#x4E00;&#x4E2A;&#x4E0D;&#x4E3A;null&#x7684;&#x503C;.<h2 id="&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;"><a href="#&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;" class="headerlink" title="&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;"></a>&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;</h2></li>
<li>case &#x6BD4;&#x8F83;&#x901A;&#x7528; case a when b then c else d end&#x3002;&#x5F53;a&#x7B49;&#x4E8E;b&#x7684;&#x65F6;&#x5019;&#x8FD4;&#x56DE;c&#xFF0C;&#x5426;&#x5219;d&#x3002;</li>
<li>decode oralce&#x51FD;&#x6570;   decode(a,&#x2019;b&#x2019;,c,&#x2019;e&#x2019;,f,g) &#x522B;&#x540D;   &#x5F53;a&#x7B49;&#x4E8E;b&#x7684;&#x65F6;&#x5019;&#x6267;&#x884C;c &#xFF0C;&#x5F53;a&#x7B49;&#x4E8E;e&#x7684;&#x65F6;&#x5019;&#x6267;&#x884C;f&#xFF0C;&#x5426;&#x5219;&#x6267;&#x884C;g&#x3002;<h2 id="&#x67E5;&#x8BE2;"><a href="#&#x67E5;&#x8BE2;" class="headerlink" title="&#x67E5;&#x8BE2;"></a>&#x67E5;&#x8BE2;</h2></li>
<li>&#x5DE6;&#x5916;&#x8FDE;&#x63A5;  &#x7B49;&#x53F7;&#x5DE6;&#x8FB9;&#x7684;&#x8868;&#x4EFB;&#x7136;&#x88AB;&#x5305;&#x542B;&#x5728;&#x6700;&#x540E;&#x7684;&#x8868;&#x4E2D; &#x5199;&#x6CD5;&#xFF1A; where a= b(+)</li>
<li>&#x81EA;&#x8FDE;&#x63A5; &#x4E00;&#x5F20;&#x8868;&#x5236;&#x5B9A;&#x4E24;&#x4E2A;&#x522B;&#x540D;&#xFF0C;&#x5F53;&#x4E24;&#x4E2A;&#x8868;&#x7528;&#x3002;</li>
<li>&#x5B50;&#x67E5;&#x8BE2;&#x5C31;&#x662F;select&#x8BED;&#x53E5;&#x7684;&#x5D4C;&#x5957;&#x3002;&#x4E0D;&#x53EF;&#x4EE5;&#x5728;group by&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;&#x3002;&#x5728;top-n&#xFF08;&#x524D;N&#x540D;&#xFF09;&#x5206;&#x6790;&#x95EE;&#x9898;&#x4E2D;&#x5FC5;&#x987B;&#x8981;&#x7ED9;&#x5B50;&#x67E5;&#x8BE2;&#x6392;&#x5E8F;&#x3002;&#x53EF;&#x4EE5;&#x5728;&#x4E3B;&#x67E5;&#x8BE2;&#x5BF9;&#x7B56;where select having from &#x540E;&#x9762;&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;</li>
<li>&#x5355;&#x884C;&#x5B50;&#x67E5;&#x8BE2;&#x2014;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#x53EA;&#x6709;&#x4E00;&#x6761;&#xFF0C;&#x53CD;&#x4E4B;&#x5C31;&#x662F;&#x591A;&#x6761;&#x5B50;&#x67E5;&#x8BE2;</li>
<li>any&#x8BED;&#x53E5; &#x53D6;&#x5176;&#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#x503C;&#x8FDB;&#x884C;&#x6BD4;&#x8F83; select * from a ehere money &gt; any(selsect money from b where c= 30) &#x53EA;&#x8981;&#x5927;&#x4E8E;&#x96C6;&#x5408;&#x7684;&#x5168;&#x90E8;&#x8FD4;&#x56DE;&#x3002;</li>
<li>all &#x53D6;&#x5176;&#x4E2D;&#x6240;&#x6709;&#x503C;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF0C;&#x7528;&#x6CD5;&#x540C;&#x4E0A;&#x3002;</li>
<li>&#x76F8;&#x5173;&#x5B50;&#x67E5;&#x8BE2;&#xFF1A;&#x5C06;&#x4E3B;&#x67E5;&#x8BE2;&#x7684;&#x503C;&#x4F20;&#x9012;&#x7ED9;&#x5B50;&#x67E5;&#x8BE2;&#x3002;</li>
</ul>
<h2 id="Oracle&#x4E2D;&#x5206;&#x9875;&#x7684;&#x5199;&#x6CD5;"><a href="#Oracle&#x4E2D;&#x5206;&#x9875;&#x7684;&#x5199;&#x6CD5;" class="headerlink" title="Oracle&#x4E2D;&#x5206;&#x9875;&#x7684;&#x5199;&#x6CD5;"></a>Oracle&#x4E2D;&#x5206;&#x9875;&#x7684;&#x5199;&#x6CD5;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">--oracle&#x5206;&#x9875;(Pageing Query)</span><br><span class="line"></span><br><span class="line">select *</span><br><span class="line">from 	(select rownum r,t1.*</span><br><span class="line"> from (select * from table order by money) t1</span><br><span class="line">	 where rownum &lt;=8</span><br><span class="line">)</span><br><span class="line">where r &gt;=5;</span><br></pre></td></tr></table></figure>
<h2 id="&#x7EA6;&#x675F;"><a href="#&#x7EA6;&#x675F;" class="headerlink" title="&#x7EA6;&#x675F;"></a>&#x7EA6;&#x675F;</h2><ul>
<li>&#x68C0;&#x67E5;&#x6027;&#x7EA6;&#x675F;check();  gender varchar(2) constraint &#x2018;&#x8FD9;&#x662F;&#x7ED9;&#x8FD9;&#x4E2A;&#x7EA6;&#x675F;&#x53D6;&#x7684;&#x540D;&#x5B57;&#x2019; check(gender in(&#x2018;&#x7537;&#x2019;,&#x2019;&#x5973;&#x2019;))&#x3002;</li>
<li>&#x5916;&#x952E;&#x7EA6;&#x675F;&#xFF1A;&#x5B50;&#x8868;&#x7684;&#x5916;&#x952E;&#x5FC5;&#x987B;&#x662F;&#x7236;&#x8868;&#x7684;&#x4E3B;&#x952E;<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">&#x8FD9;&#x4E2A;&#x8BED;&#x53E5;&#x5305;&#x542B;&#x4E86;&#x6240;&#x6709;&#x7684;&#x7EA6;&#x675F;</span><br><span class="line"></span><br><span class="line">SQL&gt; create table student</span><br><span class="line">    (</span><br><span class="line">     sid number constraint student_pk primary key,</span><br><span class="line">     sname varchar2(20) constraint student_name_notnull not null,</span><br><span class="line">     gender varchar2(2) constraint student_gender check (gender in (&apos;&#x7537;&apos;,&apos;&#x5973;&apos;)),</span><br><span class="line">     email varchar2(40) constraint student_email_unique unique</span><br><span class="line">                        constraint student_email_notnull not null,</span><br><span class="line">     deptno number constraint student_fk references dept(deptno) on delete set null</span><br><span class="line">    );</span><br></pre></td></tr></table></figure>
</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/数据库/" rel="tag"># 数据库</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/05/15/Crm总结/" rel="next" title="Crm总结">
                <i class="fa fa-chevron-left"></i> Crm总结
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/21/Maven/" rel="prev" title="Maven">
                Maven <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/me.jpg"
               alt="JokerLiang" />
          <p class="site-author-name" itemprop="name">JokerLiang</p>
          <p class="site-description motion-element" itemprop="description">永远年轻，永远热泪盈眶。</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">61</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/LoverJoker" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/lover-easy-7/activities" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/2292572142/profile?rightmod=1&wvr=6&mod=personinfo" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Friends
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.knight.ac.cn/" title="Knight" target="_blank">Knight</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://lzllzl.cn/" title="Zayvion" target="_blank">Zayvion</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://chen97.com/" title="Chens" target="_blank">Chens</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#基础"><span class="nav-number">1.</span> <span class="nav-text">基础</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数"><span class="nav-number">2.</span> <span class="nav-text">函数</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#字符类的函数"><span class="nav-number">2.0.1.</span> <span class="nav-text">字符类的函数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#数值函数"><span class="nav-number">2.0.2.</span> <span class="nav-text">数值函数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#日期函数"><span class="nav-number">2.0.3.</span> <span class="nav-text">日期函数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#转换函数"><span class="nav-number">2.0.4.</span> <span class="nav-text">转换函数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#通用函数"><span class="nav-number">2.0.5.</span> <span class="nav-text">通用函数</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#条件表达式"><span class="nav-number">3.</span> <span class="nav-text">条件表达式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#查询"><span class="nav-number">4.</span> <span class="nav-text">查询</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Oracle中分页的写法"><span class="nav-number">5.</span> <span class="nav-text">Oracle中分页的写法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#约束"><span class="nav-number">6.</span> <span class="nav-text">约束</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">JokerLiang</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	




  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

  


</body>
</html>
